//
//  LoginViewController.m
//  ForYourBeauty
//
//  Created by Kelly xu on 2019/5/24.
//  Copyright © 2019 changrenTech. All rights reserved.
//

#import "LoginViewController.h"
#import "BeautyLightTabbarViewController.h"
#import "RegViewController.h"
#import "FogotPwdViewController.h"
#import "LoginViewModel.h"
@interface LoginViewController ()
@property(nonatomic,weak)IBOutlet UIImageView *inputTextBg;
@property(nonatomic,weak)IBOutlet UIButton *logBtn;
@property(nonatomic,weak)IBOutlet UITextField *phoneText;
@property(nonatomic,weak)IBOutlet UITextField *pwdText;
@property(nonatomic,strong)LoginViewModel *loginViewModel;
@end

@implementation LoginViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    [self.inputTextBg setImage:[[UIImage imageNamed:@"cornerBg"] stretchableImageWithLeftCapWidth:[UIImage imageNamed:@"cornerBg"].size.width/2 topCapHeight:[UIImage imageNamed:@"cornerBg"].size.height/2]];
    self.logBtn.layer.cornerRadius = 30;
}
#pragma mark - 注册
-(IBAction)goRegController:(id)sender{
    RegViewController *regVC = [[RegViewController alloc]init];
    [self.rt_navigationController pushViewController:regVC animated:YES complete:nil];
}
#pragma mark - 登录
-(IBAction)logBtnPressed:(id)sender{
    if (EC_ISNullStr(self.phoneText.text)) {
        Toast(@"请输入手机号");
        return;
    }
    if (EC_ISNullStr(self.pwdText.text)) {
        Toast(@"请设置登录密码");
        return;
    }
    [self.loginViewModel loginWithMob:self.phoneText.text pwd:self.pwdText.text cmp:^{
        BeautyLightTabbarViewController *tabVC = [[BeautyLightTabbarViewController alloc]init];
        RTRootNavigationController *nav = [[RTRootNavigationController alloc]initWithRootViewController:tabVC];
        [JumpTools setRootCtrl:nav];
    }];
}
-(IBAction)fogotPwd:(id)sender{
    FogotPwdViewController *fogotPwd = [[FogotPwdViewController alloc]init];
    [self.rt_navigationController pushViewController:fogotPwd animated:YES complete:nil];
}
#pragma mark - instance
-(LoginViewModel*)loginViewModel{
    if (!_loginViewModel) {
        _loginViewModel = [[LoginViewModel alloc]init];
    }
    return _loginViewModel;
}
/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
